const router = require('koa-router')()

module.exports = (app) => {
    router.redirect('/', '/login')
    router.get('/login', require('./user').login)
    router.post('/login', require('./user').login)
    router.get('/home', require('./common').home)
    router.get('/basic/*', require('./basic').index)
    router.get('/components/*', require('./components').index)


    app
        .use(router.routes())
        .use(router.allowedMethods())

    // 404
    app.use(async (ctx, next) => {
        await ctx.render('error/404', {
            title: 'page not find'
        })
    })
}